﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DynamicViewFormApp.Util
{
    class ControlFindUtil
    {
        /// <summary>
        /// 通过控件名获取控件
        /// </summary>
        /// <param name="pCtl">控件所在的容器或者窗体</param>
        /// <param name="ctlName">需要查找的控件名</param>
        /// <returns></returns>
        internal static Control GetControlByName(Panel pCtl, string ctlName)
        {
            Control[] ctls = pCtl.Controls.Find(ctlName, false);
            if (ctls.Length > 0)
            {
                return ctls[0];
            }
            else
            {
                return null;
            }
        }

    }
}
